package com.barnaby.sudoku;

import android.R;
import android.os.Bundle;
import android.view.View;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.graphics.drawable.shapes.Shape;

public class Experiment extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(new ExperimentalGraphicsView(this));
	}
	
	static public class ExperimentalGraphicsView extends View{
		@SuppressLint("NewApi")
		@SuppressWarnings("deprecation")
		public ExperimentalGraphicsView(Context context){
			super(context);
			GradientDrawable g = new GradientDrawable();
			/*g.setOrientation(Orientation.BOTTOM_TOP);
			int colors[] = new int[1];
			colors[0] = Color.RED;
			colors[1] = Color.BLUE;
			g.setColors(new int[] {Color.RED, Color.BLUE}); //(Color.RED);
*/			setBackgroundDrawable(g);
		}
		
		@SuppressLint("DrawAllocation")
		@Override
		protected void onDraw(Canvas canvas){
			Paint cPaint;
			cPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
			cPaint.setColor(Color.LTGRAY);
			cPaint.setStyle(Paint.Style.STROKE);
			cPaint.setStrokeWidth(3);
			
			Paint tPaint;
			tPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
			tPaint.setStyle(Paint.Style.FILL_AND_STROKE);
			tPaint.setColor(Color.BLACK);
			
			float scale = getResources().getDisplayMetrics().scaledDensity;
			tPaint.setTextSize(18 * scale);
			
			Path circle = new Path();
			float density = getResources().getDisplayMetrics().density;
			circle.addCircle(150 * density, 150 * density, 100 * density, Direction.CW);
			String quote = "My cook asks not whether the guests have arrived, rather has the hour come.";
			canvas.drawPath(circle, cPaint);
			canvas.drawTextOnPath(quote, circle, 0, tPaint.getTextSize(), tPaint);
			
		}
	}
	
}

